# 设置C++标准
cmake_minimum_required(VERSION 3.10)
project(my_terminal_test)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# set(CMAKE_C_COMPILER "gcc")
set(PROJECT_SOURCE_FILE_PATH "../")
set(CMAKE_VERBOSE_MAKEFILE ON)

# 只对src目录启用覆盖率
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")

set_property(GLOBAL PROPERTY INCLUDE_FILE)
set_property(GLOBAL PROPERTY SOURCE_FILE)
set_property(GLOBAL PROPERTY LINK_LIB)


add_subdirectory(${PROJECT_SOURCE_FILE_PATH}/src/ build)
get_property(SOURCE_FILE GLOBAL PROPERTY SOURCE_FILE)
get_property(INCLUDE_FILE GLOBAL PROPERTY INCLUDE_FILE)
get_property(LINK_LIB GLOBAL PROPERTY LINK_LIB)

add_executable(my_terminal_test ${SOURCE_FILE} test_main.cpp webcli_test.cpp)

list(APPEND TEST_INCLUDE_FILE ${PROJECT_SOURCE_FILE_PATH}/third_party/mockcpp/3rdparty)
list(APPEND TEST_INCLUDE_FILE ${PROJECT_SOURCE_FILE_PATH}/third_party/mockcpp/include)
list(APPEND TEST_INCLUDE_FILE ${PROJECT_SOURCE_FILE_PATH}/third_party/googletest/googletest/include)
list(APPEND TEST_INCLUDE_FILE ${PROJECT_SOURCE_FILE_PATH}/third_party/googletest/googlemock/include)
target_include_directories(my_terminal_test PRIVATE ${INCLUDE_FILE} ${TEST_INCLUDE_FILE})

# 添加测试可执行文件

list(APPEND TEST_LIB ${CMAKE_CURRENT_SOURCE_DIR}/../third_party/mockcpp/build_GNU/mockcpp/src/libmockcpp.a)
list(APPEND TEST_LIB ${CMAKE_CURRENT_SOURCE_DIR}/../third_party/googletest/build/lib/libgmock_main.a)
list(APPEND TEST_LIB ${CMAKE_CURRENT_SOURCE_DIR}/../third_party/googletest/build/lib/libgmock.a)
list(APPEND TEST_LIB ${CMAKE_CURRENT_SOURCE_DIR}/../third_party/googletest/build/lib/libgtest_main.a)
list(APPEND TEST_LIB ${CMAKE_CURRENT_SOURCE_DIR}/../third_party/googletest/build/lib/libgtest.a)

target_link_libraries(my_terminal_test ${LINK_LIB} ${TEST_LIB})

add_compile_options(${CFLAGS})
target_compile_definitions(my_terminal_test PRIVATE LLT=1)
add_link_options(--coverage)
